package helper;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.jdesktop.beansbinding.Converter;

public class DateStringConverter extends Converter<Date, String> {

	SimpleDateFormat df = new SimpleDateFormat("MM/yyyy");
	
	@Override
	public String convertForward(Date value) {
		return df.format(value);
	}

	@Override
	public Date convertReverse(String value) {
		try {
			return df.parse(value);
		} catch (ParseException e) {
			throw new RuntimeException("DateStringConverter: DateFormat cannot be parsed");
		}
	}
}
